<?php
/**
 * Buffet Framework - Filter Hooks
 * 
 * This file contains all the functions for the theme's filters, and their default content.
 * 
 * @package Buffet
 * @subpackage API
 */
 
function bf_wrapper_class() {
	echo 'class="' . apply_filters('bf_wrapper_class', 'clearfix') . '"';	
}

function bf_main_class() {
	echo 'class="' . apply_filters('bf_main_class', 'clearfix') . '"';
}

function bf_container_class() {
	echo 'class="' . apply_filters('bf_container_class', 'clearfix') . '"';	
}

function bf_header_class() {
	echo 'class="' . apply_filters('bf_header_class', 'header') . '"';	
}

function bf_content_class() {
	echo 'class="' . apply_filters('bf_content_class', 'section') . '"';		
}

function bf_empty_filter() {
	return null;	
}

/**
 * remove_gallery_css() - Removes WordPress' gallery CSS
 * 
 * This function removes the inline stylesheet generated by WordPress' in-built gallery,
 * which invalidates the HTML code from web standards.
 * 
 * @since	0.5.2
 * @todo	Move this to some other file, it does not belong here.
 * @return	string	HTML code
 */
function remove_gallery_css() {
	return '<div class="gallery">';	
}

/**
 * bf_doctype() - Buffet Framework filter function
 * 
 * Renders the current DOCTYPE of the page. By default it displays the XHTML 1.0 Transitional
 * doctype.
 * 
 * @since	0.5.2
 * @hook	filter	bf_doctype
 * @return	string	HTML code
 */
function bf_doctype() {
	echo apply_filters('bf_doctype', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
}

/**
 * bf_newsheader() - Buffet Framework filter function
 * 
 * Displays news information before its content (summary). By default, it displays the header.
 * You can override this using the <b>bf_newsheader</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_newsheader
 * @return	string	HTML code
 */
function bf_newsheader() {
	global $post;
	$postheader = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$postheader .= '<h4 class="entry-title"><a title="' . sprintf( __('Permalink to %s', 'buffet'), get_the_title() ) . '" href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h4>';
	}
	echo apply_filters('bf_newsheader', $postheader);
}

/**
 * bf_newsbody() - Buffet Framework filter function
 * 
 * Displays news content (summary). By default, it displays the first 50 words of the article.
 * You can override this using the <b>bf_newsbody</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_newsbody
 * @return	string	HTML code
 */
function bf_newsbody() {
	global $post;
	
	$output = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$output .= '<div class="entry-summary">';
		
		$content = explode( ' ', strip_tags(get_the_content()) );
		if( count($content) > 50) {
			$content = array_slice($content, 0, 50);
		}
		$output .= implode($content, ' ') . '...';
	
		$output .= '</div><!-- .entry-summary -->';
		
		$output .= '<a class="more-link" href="' . get_permalink() . '">' . __('Read More', 'buffet') . '</a>';
	}
	
	echo apply_filters('bf_newsbody', $output);
}

/**
 * bf_newsfooter() - Buffet Framework filter function
 * 
 * Displays news information after its content (summary). By default, it displays nothing.
 * You can override this using the <b>bf_newsfooter</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_newsfooter
 * @return	string	HTML code
 */
function bf_newsfooter() {
	global $post;
	
	$postfooter = '';
	
	echo apply_filters('bf_newsfooter', $postfooter);
}

/**
 * bf_archive_postheader() - Buffet Framework filter function
 * 
 * Displays post information before its content (summary) in the archive template. By default, it displays the header.
 * You can override this using the <b>bf_archive_postheader</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_archive_postheader
 * @return	string	HTML code
 */
function bf_archive_postheader() {
	global $post;
	$postheader = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$postheader .= '<h4 class="entry-title"><a title="' . sprintf( __('Permalink to %s', 'buffet'), get_the_title() ) . '" href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h4>';
	}
	echo apply_filters('bf_archive_postheader', $postheader);
}

/**
 * bf_archive_postbody() - Buffet Framework filter function
 * 
 * Displays post content (summary) in the archive template. By default, it displays the first 50 words of the article.
 * You can override this using the <b>bf_archive_postbody</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_archive_postbody
 * @return	string	HTML code
 */
function bf_archive_postbody() {
	global $post;
	
	$output = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$output = '<div class="entry-summary">';
		
		$content = explode( ' ', strip_tags(get_the_content()) );
		if( count($content) > 50) {
			$content = array_slice($content, 0, 50);
		}
		$output .= implode($content, ' ') . '...';
	
		$output .= '</div><!-- .entry-summary -->';
		
		$output .= '<a class="more-link" href="' . get_permalink() . '">' . __('Read More', 'buffet') . '</a>';
	}
	
	echo apply_filters('bf_archive_postbody', $output);
}

/**
 * bf_archive_postfooter() - Buffet Framework filter function
 * 
 * Displays post information after its content (summary) in the archive template. By default, it displays nothing.
 * You can override this using the <b>bf_newsfooter</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_archive_postfooter
 * @return	string	HTML code
 */
function bf_archive_postfooter() {
	global $post;
	
	$postfooter = '';
	
	echo apply_filters('bf_archive_postfooter', $postfooter);
}

/**
 * bf_search_postheader() - Buffet Framework filter function
 * 
 * Displays post information before its content (summary) in the search template. By default, it displays the header.
 * You can override this using the <b>bf_search_postheader</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_search_postheader
 * @return	string	HTML code
 */
function bf_search_postheader() {
	global $post;
	$postheader = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$postheader .= '<h4 class="entry-title"><a title="' . sprintf( __('Permalink to %s', 'buffet'), get_the_title() ) . '" href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h4>';
	}
	
	echo apply_filters('bf_search_postheader', $postheader);
}

/**
 * bf_search_postbody() - Buffet Framework filter function
 * 
 * Displays post content (summary) in the search template. By default, it displays the first 50 words of the article.
 * You can override this using the <b>bf_search_postbody</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_search_postbody
 * @return	string	HTML code
 */
function bf_search_postbody() {
	global $post;
	
	$output = '';	
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$output = '<div class="entry-summary">';
		
		$content = explode( ' ', strip_tags(get_the_content()) );
		if( count($content) > 50) {
			$content = array_slice($content, 0, 50);
		}
		$output .= implode($content, ' ') . '...';
	
		$output .= '</div><!-- .entry-summary -->';
		
		$output .= '<a class="more-link" href="' . get_permalink() . '">' . __('Read More', 'buffet') . '</a>';
	}
	
	echo apply_filters('bf_search_postbody', $output);
}

/**
 * bf_search_postfooter() - Buffet Framework filter function
 * 
 * Displays post information after its content (summary) in the search template. By default, it displays nothing.
 * You can override this using the <b>bf_search_postfooter</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_search_postfooter
 * @return	string	HTML code
 */
function bf_search_postfooter() {
	global $post;
	
	$postfooter = '';
	
	echo apply_filters('bf_search_postfooter', $postfooter);
}

/**
 * bf_postheader() - Buffet Framework filter function
 * 
 * Displays post meta information before its content body. By defauly it displays the title, author, date and its tags.
 * You can override this using the <b>bf_postheader</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_postheader
 * @return 	string	HTML code
 */
function bf_postheader() {
	global $post;
	
	$postheader = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		if ( is_attachment() ) $postheader .= '<h1 class="entry-title" id="post-' . $post->ID . '">' . get_the_title() . ' [<a href="' . get_permalink($post->post_parent) . '" rev="attachment">' . get_the_title($post->post_parent) . '</a>]</h1>';
		else $postheader .= '<h1 class="entry-title" id="post-' . $post->ID . '"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h1>';
			
		$postheader .= '<div class="entry-meta clearfix">';
		$postheader .= sprintf( __('<span class="author vcard">By <span class="fn">%s</span></span>', 'buffet'), get_the_author() );
		$postheader .= sprintf( __('<span class="published">Published: <abbr class="date" title="%1$s">%2$s at %3$s</abbr></span>', 'buffet'), get_the_time( __('c', 'buffet') ), get_the_time( __('F j, Y', 'buffet') ), get_the_time( __('g:i A', 'buffet') ) );
		
		if ( !is_attachment() )
			$postheader .= __('<span class="entry-tags">Tags:', 'buffet') . get_the_tag_list(' ', ', ', ' ') . '</span>';
		
		$postheader .= '</div><!-- .entry-meta -->';
	}
	
	echo apply_filters('bf_postheader', $postheader);
}

/**
 * bf_postfooter() - Buffet Framework filter function
 * 
 * Displays post meta information after its content body. By default, it contains a link to the post's comments, 
 * link to print page (with WP-Print plugin), as well as social networking links to Digg, Facebook and Twitter.
 * 
 * You can override this using the <b>bf_postfooter</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_postfooter
 * @return	string	HTML code
 */
function bf_postfooter() {
	global $id, $post;
	
	$postheader = '';
	
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$postfooter .= '<div class="break"></div>';
		
		if ( !is_attachment() ) {
			$postfooter .= '<ul class="entry-links clearfix">';
			$postfooter .= '<li><a href="' . get_comments_link() . '">' . __('Comments', 'buffet') . ' [' . get_comments_number() . ']</a></li>';
			if ( function_exists('wp_print') ) $postheader .= '<li>' . print_link('', '', false) . '</li>';
			
			// Add social bookmarking buttons
			$postfooter .= '<li><a rev="vote-for" title="' . __('Submit to Digg!', 'buffet') . '" href="http://digg.com/submit?phase=2&amp;url=' . urlencode(get_permalink()) . '&amp;title=' . urlencode(get_the_title()) . '">' . __('Digg it!', 'buffet') . '</a></li>';
			$postfooter .= '<li><a rev="vote-for" title="' . __('Post it to your Facebook Profile', 'buffet') . '" href="http://www.facebook.com/share.php?u=' . urlencode(get_permalink()) . '&amp;t=' . urlencode(get_the_title()) . '">' . __('Facebook', 'buffet') . '</a></li>';
			$postfooter .= '<li><a rev="vote-for" title="' . __('Twitter', 'buffet') . '" href="http://twitter.com/home?status=' . urlencode(get_permalink()) . '">' . __('Twitter', 'buffet') . '</a></li>';
			
			$postfooter .= '<li><a title="' . __('Edit Post', 'buffet') . '" href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?action=edit&post=' . $id . '">' . __('Edit Post', 'buffet') . '</a></li>';
			$postfooter .= '</ul>';
		}
	}
	echo apply_filters('bf_postfooter', $postfooter);
}

/**
 * bf_pageheader() - Buffet Framework filter function
 * 
 * Displays news information before its content (summary). By default, it displays the header.
 * You can override this using the <b>bf_pageheader</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_pageheader
 * @return	string	HTML code
 */
function bf_pageheader() {
	$pageheader = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$pageheader = '<h1 class="entry-title" id="post-' . $post->ID . '"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h1>';
	}
	echo apply_filters('bf_pageheader', $pageheader);
}

/**
 * bf_pagefooter() - Buffet Framework filter function
 * 
 * Displays post meta information after its content body. By default, it contains a link to print page (with WP-Print plugin), 
 * as well as social networking links to Digg, Facebook and Twitter.
 * 
 * You can override this using the <b>bf_pagefooter</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_pagefooter
 * @return	string	HTML code
 */
function bf_pagefooter() {
	global $id;
	
	$pagefooter = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$pagefooter .= '<ul class="entry-links clearfix">';
		if ( function_exists('wp_print') ) $pagefooter .= '<li>' . print_link('', '', false) . '</li>';
		
		// Add social bookmarking buttons
		$pagefooter .= '<li><a rev="vote-for" title="' . __('Submit to Digg!', 'buffet') . '" href="http://digg.com/submit?phase=2&amp;url=' . urlencode(get_permalink()) . '&amp;title=' . urlencode(get_the_title()) . '">' . __('Digg it!', 'buffet') . '</a></li>';
		$pagefooter .= '<li><a rev="vote-for" title="' . __('Post it to your Facebook Profile', 'buffet') . '" href="http://www.facebook.com/share.php?u=' . urlencode(get_permalink()) . '&amp;t=' . urlencode(get_the_title()) . '">' . __('Facebook', 'buffet') . '</a></li>';
		$pagefooter .= '<li><a rev="vote-for" title="' . __('Twitter', 'buffet') . '" href="http://twitter.com/home?status=' . urlencode(get_permalink()) . '">' . __('Twitter', 'buffet') . '</a></li>';
		
		$pagefooter .= '<li><a title="' . __('Edit Post', 'buffet') . '" href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?action=edit&post=' . $id . '">' . __('Edit Post', 'buffet') . '</a></li>';
		$pagefooter .= '</ul>';
	}
	echo apply_filters('bf_pagefooter', $pagefooter);
}

/**
 * bf_postmeta() - Buffet Framework filter function
 * 
 * Displays post information right before the post content. Useful if you wish to display review ratings before your content.
 * By default, it displays nothing. You can override this using the <b>bf_postmeta</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_postmeta
 * @return	string	HTML code
 */
function bf_postmeta() {
	global $post;

	$postmeta = '';
	
	echo apply_filters('bf_postmeta', $postmeta);	
}

/**
 * bf_commentheader() - Buffet Framework filter function
 * 
 * Displays comment meta information before the comment's content. By default it displays the avatar, name and date.
 * You can override this using the <b>bf_commentheader</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_commentheader
 * @return	string	HTML code
 */
function bf_commentheader() {
	global $comment;
	
	$commentheader = '';
	
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$commentheader .= '<div class="comment-author vcard">';
		$commentheader .= get_avatar($comment, $size = 48);
		$commentheader .= sprintf( __('<cite class="fn">%s</cite> <span class="says">says:</span>', 'buffet'), get_comment_author_link() );
		$commentheader .= '</div>';
		
		if ( $comment->comment_approved == '0' ) {
			$commentheader .= '<span class="comment-moderation">' . __('Your comment is awaiting moderation.') . '</span>';	
		}
		
		$commentheader .= '<div class="comment-meta commentmetadata">';
		$commentheader .= sprintf( __('Posted <abbr class="comment-datetime" title="%1$s">%2$s at %3$s</abbr>', 'buffet'), get_comment_time('c'), get_comment_time( __('F j, Y', 'buffet') ), get_comment_time( __('g:i A', 'buffet') ) );
		$commentheader .= '</div>';
	}
	echo apply_filters('bf_commentheader', $commentheader);
}

/**
 * bf_commentfooter() - Buffet Framework filter function
 * 
 * Displays comment meta information after the comment's content. By default it displays nothing.
 * You can override this using the <b>bf_commentfooter</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_commentfooter
 * @return	string	HTML code
 */
function bf_commentfooter() {
	echo apply_filters('bf_commentfooter', null);
}

/**
 * bf_trackback() - Buffet Framework filter function
 * 
 * Displays trackback information. By default it displays the link to the trackback.
 * You can override this using the <b>bf_trackback</b> filter.
 *
 * @since	0.5.2
 * @hook	filter	bf_trackback
 * @return	string	HTML code
 */
function bf_trackback() {
	global $comment;
	$trackbackcontent = get_comment_author_link();
	
	echo apply_filters('bf_trackback', $trackbackcontent);
}

/**
 * bf_post_notfound() - Buffet Framework filter function
 * 
 * Displays when the specified post/archive requested by the user is not found.
 * You can override this using the <b>bf_post_notfound</b> filter.
 * 
 * @since	0.5.2
 * @hook	filter	bf_post_notfound
 * @return	string	HTML code
 */
function bf_post_notfound() {
	$postcontent = '';
	if ( !defined('BF_DEVELOPER_MODE') || !BF_DEVELOPER_MODE ) {
		$postcontent .= '<h2>' . __('That \'something\' you are looking for isn\'t here!', 'buffet') . '</h2>';
		$postcontent .= '<p>' . __('<strong>We\'re very sorry, but that page doesn\'t exist or has been moved.</strong><br />Please make sure you have the right URL.', 'buffet') . '</p>';
	}	
	echo apply_filters('bf_post_notfound', $postcontent);	
}

/**
 * bf_rss_url() - RSS Feed URL Function
 * 
 * Returns the link to the blog's RSS feed (from theme options or default).
 * You can override this using the <b>bf_rss_url</b> filter.
 * 
 * @hook	filter	bf_rss_url
 * @since	0.5.3
 */
function bf_rss_url() {
	if ( bf_get_option('feed_url') != '' ) $output = bf_get_option('feed_url');
	else $output = get_bloginfo('rss2_url');
	
	echo apply_filters('bf_rss_url', $output);
}

/**
 * bf_comments_rss_url() - RSS Comments Feed URL Function
 * 
 * Returns the link to the blog's RSS comments feed (from theme options or default).
 * You can override this using the <b>bf_comments_rss_url</b> filter.
 * 
 * @hook	filter	bf_comments_rss_url
 * @since	0.5.3
 */
function bf_comments_rss_url() {
	if ( bf_get_option('comments_feed_url') != '' ) $output = bf_get_option('comments_feed_url');
	else $output = get_bloginfo('comments_rss2_url');	
	
	echo apply_filters('bf_comments_rss_url', $output);
}

/* End of file filters.php */
/* Location: ./includes/filters.php */
